package com.insight.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * T128: OpenAPI 3.0 配置
 * 自动生成 RESTful API 文档
 *
 * @author Insight Team
 */
@Configuration
public class OpenApiConfig {

    @Value("${spring.application.name:Insight Metadata Management System}")
    private String applicationName;

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("Insight Metadata Management API")
                        .version("1.0.0")
                        .description("企业级元数据管理系统 RESTful API 文档\n\n" +
                                "## 功能特性\n" +
                                "- 多数据源元数据采集 (Oracle, MySQL, PostgreSQL, SQL Server, TiDB, 达梦)\n" +
                                "- 元数据版本管理与变更追踪\n" +
                                "- 数据字典自动生成 (Excel/PDF/Word/Markdown)\n" +
                                "- 全文检索 (基于ParadeDB BM25,支持中文分词)\n" +
                                "- 表关系可视化分析\n\n" +
                                "## 技术栈\n" +
                                "- Spring Boot 3.2.0\n" +
                                "- Java 21 Virtual Threads\n" +
                                "- ParadeDB (PostgreSQL 15 + pg_search)\n" +
                                "- Redis 7.x\n" +
                                "- Kafka 3.6.0\n" +
                                "- MinIO 对象存储")
                        .contact(new Contact()
                                .name("Insight Team")
                                .email("insight@example.com")
                                .url("https://github.com/insight/metadata-management"))
                        .license(new License()
                                .name("Apache 2.0")
                                .url("https://www.apache.org/licenses/LICENSE-2.0")))
                .servers(List.of(
                        new Server()
                                .url("http://localhost:8080")
                                .description("本地开发环境"),
                        new Server()
                                .url("http://insight-api:8080")
                                .description("生产环境")
                ));
    }
}
